package com.android.task5;

import android.util.Log;

public class FlickrPhoto {
	
	private final static String INFO_TAG = "Flickr Photo Info";
	
	
	private String farmId;
	private String serverId;
	private String photoId;
	private String secret;
	private String title;
	private String authorUserName;
	private String authorRealName;
	
	private String downloadUrl;
	private boolean sizeSet;
	
	//size specifiers
	private final static String SIZE_SMALL_SQUARE = "_s.jpg";	// 75x75
	private final static String SIZE_THUMBNAIL = "_t.jpg"; //100 on longest side
	private final static String SIZE_SMALL = "_m.jpg";	//240 on longest side
	private final static String SIZE_MEDIUM = ".jpg";	//500 on longest side
	private final static String SIZE_LARGE = "_b.jpg"; 	//1024 on longest side
	
	public FlickrPhoto(String farmId, String serverId, String photoId, String secret){
		this.setFarmId(farmId);
		this.setServerId(serverId);
		this.setPhotoId(photoId);
		this.setSecret(secret);
		
		downloadUrl = "http://farm";
		downloadUrl += farmId;
		downloadUrl += ".static.flickr.com/";
		downloadUrl += serverId;
		downloadUrl += "/";
		downloadUrl += photoId;
		downloadUrl += "_";
		downloadUrl += secret; 
		
		sizeSet = false;
	}
	
	public void setImageSizeSmallSquare(){
		downloadUrl += SIZE_SMALL_SQUARE;
		sizeSet = true;
	}
	
	public void setImageSizeThumbnail(){
		downloadUrl += SIZE_THUMBNAIL;
		sizeSet = true;
	}
	
	public void setImageSizeSmall(){
		downloadUrl += SIZE_SMALL;
		sizeSet = true;
	}
	
	public void setImageSizeMedium(){
		downloadUrl += SIZE_MEDIUM;
		sizeSet = true;
	}
	
	public void setImageSizeLarge(){
		downloadUrl += SIZE_LARGE;
		sizeSet = true;
	}
	
	public String getDownloadUrl(){
		if(!sizeSet) setImageSizeSmall();
		return downloadUrl;
	}
	
	public void getInfo(){
		Log.i(INFO_TAG, getDownloadUrl());
	}

	public void setFarmId(String farmId) {
		this.farmId = farmId;
	}

	public String getFarmId() {
		return farmId;
	}

	public void setServerId(String serverId) {
		this.serverId = serverId;
	}

	public String getServerId() {
		return serverId;
	}

	public void setPhotoId(String photoId) {
		this.photoId = photoId;
	}

	public String getPhotoId() {
		return photoId;
	}

	public void setSecret(String secret) {
		this.secret = secret;
	}

	public String getSecret() {
		return secret;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getAuthorUserName() {
		return authorUserName;
	}

	public void setAuthorUserName(String authorUserName) {
		Log.i("http","username: "+authorUserName);
		this.authorUserName = authorUserName;
	}

	public String getAuthorRealName() {
		return authorRealName;
	}

	public void setAuthorRealName(String authorRealName) {
		this.authorRealName = authorRealName;
	}
}
